package com.moss.cloud.base.biz.operation.flow.impl;

import com.moss.cloud.base.api.model.from.FlowTaskFrom;
import com.moss.cloud.base.biz.operation.flow.BusStateOperation;
import com.moss.cloud.base.biz.service.impl.FlowTaskServiceImpl;
import com.moss.cloud.common.core.utils.SpringContextHolder;
import com.moss.cloud.common.flow.enums.TaskState;
import com.moss.cloud.common.flow.model.NodeTask;
import lombok.extern.slf4j.Slf4j;


@Slf4j
public class PassState implements BusStateOperation {

    @Override
    public void stateProcess(NodeTask nodeTask) {
        log.info("通过的任务:{},任务名称:{}", nodeTask.getId(), nodeTask.getName());
        FlowTaskServiceImpl flowTaskService = SpringContextHolder.getBean(FlowTaskServiceImpl.class);
        FlowTaskFrom from = new FlowTaskFrom();
        from.setId(nodeTask.getId());
        from.setStatus(TaskState.PASS.getType());
        flowTaskService.update(from);
        log.info("给审申请人发一个任务通过提醒通知:{}", nodeTask.getBusId());
    }
}
